package com.xinzhi.savingpot.rminfo.service.impl;


import com.xinzhi.savingpot.rminfo.entity.Recordinfo;
import com.xinzhi.savingpot.rminfo.mapper.IRecordAllMapper;
import com.xinzhi.savingpot.rminfo.pojo.RecordAllVo;
import com.xinzhi.savingpot.rminfo.service.IRecordAllService;
import com.xinzhi.savingpot.util.BaseResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RecordinfoAllImpl implements IRecordAllService {
    @Autowired
    IRecordAllMapper iRecordAllMapper;

    @Override
    public BaseResponse findRecordinfoAll(int userid) {
        RecordAllVo rav = new RecordAllVo();
        List<Recordinfo> recordAll = iRecordAllMapper.getRecordAll(userid);
        if (!recordAll.isEmpty()){
            for (Recordinfo re: recordAll) {
                if (re.getFkcriminalrecordsid().getScore()==null){
                    return new BaseResponse(300, "暂无数据", null);
                }
                rav.setPointsthat(re.getFkcriminalrecordsid().getPointsthat());
                rav.setScore(re.getFkcriminalrecordsid().getScore());
                rav.setFilmtime(re.getFilmtime());
            }
            return new BaseResponse(200,"查询成功",rav);
        }
        return new BaseResponse(400, "暂无违规行为", null);
    }
}
